***When HOGS Fly - Jonathan D. Moyer (jmoyer@du.edu) et al. - ISQ***
*Do file: Collin J. Meisel (collin.meisel@du.edu) - December 2024

*Notes: 
	*1. Code written & run in Stata 15 SE. 
	*2.This file requires you first install ppmlhdfe. Type: findit ppmlhdfe
	*3. This file also requires you install center. Type: ssc install center

*Set directory
cd /*SET FILE DIRECTORY -- place all replication files in this folder*/

********************************************************************************
**External validation
********************************************************************************

	***Wang & Stone (2022); Kastner & Saunders (2012) - Chinese President
		*prep W&S
		use china_visits.v1.dta,clear

		keep if office=="President"
		egen countryyear = group(country year)
		gen one = 1
		egen tripsabroad_WS = total(one),by(year)

		gen countrya="China"
		gen iso3a="CHN"
		order countrya iso3a year tripsabroad

		keep countrya iso3a year tripsabroad
		duplicates drop
		browse
		save WS-COLT_China-comparison.dta, replace

		*prep COLT
		clear
		import excel "Diplometrics_COLT_Travel_Dataset_20240711.xlsx", sheet("Master") firstrow
		
		keep if LeaderCountryISO=="CHN" & PriorityLeader=="Yes" & inrange(TripYear,1998,2020)
		gen one = 1
		egen tripsabroad_COLT = total(one),by(TripYear)
		
		rename TripYear year
		rename LeaderCountryISO iso3a
		order iso3a year tripsabroad_COLT
		
		keep iso3a year tripsabroad_COLT
		duplicates drop
		browse
		save COLT-China-leader-data-prep.dta, replace
		
		clear
		use WS-COLT_China-comparison.dta
		merge 1:1 iso3a year using "COLT-China-leader-data-prep.dta"
		drop _merge
		save WS-COLT_China-comparison_merged.dta, replace
		
		*compare
		corr tripsabroad_WS tripsabroad_COLT
		twoway(line tripsabroad_WS year)(line tripsabroad_COLT year),legend(label(1 "Wang & Stone (2022)")label(2 "COLT")) xtitle("") /*
		*/ylabel(,angle(horizontal)) ytitle("Trips abroad") title("President of China") text(22.4 2016 "r = 0.957",place(e))
		graph save WS-COLT_China-comparison.gph, replace
		
		*prep K&S
		use HuWenReplication.dta, clear

		gen iso = ""
		replace iso = "AFG" if ccode == 700
		replace iso = "ALB" if ccode == 339
		replace iso = "DZA" if ccode == 615
		replace iso = "AND" if ccode == 232
		replace iso = "AGO" if ccode == 540
		replace iso = "ATG" if ccode == 58
		replace iso = "ARG" if ccode == 160
		replace iso = "ARM" if ccode == 371
		replace iso = "AUS" if ccode == 900
		replace iso = "AUT" if ccode == 305
		replace iso = "AZE" if ccode == 373
		replace iso = "BHS" if ccode == 31
		replace iso = "BHR" if ccode == 692
		replace iso = "BGD" if ccode == 771
		replace iso = "BRB" if ccode == 53
		replace iso = "BLR" if ccode == 370
		replace iso = "BEL" if ccode == 211
		replace iso = "BLZ" if ccode == 80
		replace iso = "BEN" if ccode == 434
		replace iso = "BTN" if ccode == 760
		replace iso = "BOL" if ccode == 145
		replace iso = "BIH" if ccode == 346
		replace iso = "BWA" if ccode == 571
		replace iso = "BRA" if ccode == 140
		replace iso = "BRN" if ccode == 835
		replace iso = "BGR" if ccode == 355
		replace iso = "BFA" if ccode == 439
		replace iso = "BDI" if ccode == 516
		replace iso = "KHM" if ccode == 811
		replace iso = "CMR" if ccode == 471
		replace iso = "CAN" if ccode == 20
		replace iso = "CPV" if ccode == 402
		replace iso = "CAF" if ccode == 482
		replace iso = "TCD" if ccode == 483
		replace iso = "CHL" if ccode == 155
		replace iso = "CHN" if ccode == 710
		replace iso = "COL" if ccode == 100
		replace iso = "COM" if ccode == 581
		replace iso = "COG" if ccode == 484
		replace iso = "CRI" if ccode == 94
		replace iso = "HRV" if ccode == 344
		replace iso = "CUB" if ccode == 40
		replace iso = "CYP" if ccode == 352
		replace iso = "CZE" if ccode == 316
		replace iso = "CSK" if ccode == 315
		replace iso = "COD" if ccode == 490
		replace iso = "DNK" if ccode == 390
		replace iso = "DJI" if ccode == 522
		replace iso = "DMA" if ccode == 54
		replace iso = "DOM" if ccode == 42
		replace iso = "TLS" if ccode == 860
		replace iso = "ECU" if ccode == 130
		replace iso = "EGY" if ccode == 651
		replace iso = "SLV" if ccode == 92
		replace iso = "GNQ" if ccode == 411
		replace iso = "ERI" if ccode == 531
		replace iso = "EST" if ccode == 366
		replace iso = "ETH" if ccode == 530
		replace iso = "FSM" if ccode == 987
		replace iso = "FJI" if ccode == 950
		replace iso = "FIN" if ccode == 375
		replace iso = "FRA" if ccode == 220
		replace iso = "GAB" if ccode == 481
		replace iso = "GMB" if ccode == 420
		replace iso = "GEO" if ccode == 372
		replace iso = "DDR" if ccode == 265
		replace iso = "FRG" if ccode == 260
		replace iso = "DEU" if ccode == 255
		replace iso = "GHA" if ccode == 452
		replace iso = "GRC" if ccode == 350
		replace iso = "GRD" if ccode == 55
		replace iso = "GTM" if ccode == 90
		replace iso = "GIN" if ccode == 438
		replace iso = "GNB" if ccode == 404
		replace iso = "GUY" if ccode == 110
		replace iso = "HTI" if ccode == 41
		replace iso = "HND" if ccode == 91
		replace iso = "HUN" if ccode == 310
		replace iso = "ISL" if ccode == 395
		replace iso = "IND" if ccode == 750
		replace iso = "IDN" if ccode == 850
		replace iso = "IRN" if ccode == 630
		replace iso = "IRQ" if ccode == 645
		replace iso = "IRL" if ccode == 205
		replace iso = "ISR" if ccode == 666
		replace iso = "ITA" if ccode == 325
		replace iso = "CIV" if ccode == 437
		replace iso = "JAM" if ccode == 51
		replace iso = "JPN" if ccode == 740
		replace iso = "JOR" if ccode == 663
		replace iso = "KAZ" if ccode == 705
		replace iso = "KEN" if ccode == 501
		replace iso = "KIR" if ccode == 946
		replace iso = "XKX" if ccode == 347
		replace iso = "KWT" if ccode == 690
		replace iso = "KGZ" if ccode == 703
		replace iso = "LAO" if ccode == 812
		replace iso = "LVA" if ccode == 367
		replace iso = "LBN" if ccode == 660
		replace iso = "LSO" if ccode == 570
		replace iso = "LBR" if ccode == 450
		replace iso = "LBY" if ccode == 620
		replace iso = "LIE" if ccode == 223
		replace iso = "LTU" if ccode == 368
		replace iso = "LUX" if ccode == 212
		replace iso = "MKD" if ccode == 343
		replace iso = "MDG" if ccode == 580
		replace iso = "MWI" if ccode == 553
		replace iso = "MYS" if ccode == 820
		replace iso = "MDV" if ccode == 781
		replace iso = "MLI" if ccode == 432
		replace iso = "MLT" if ccode == 338
		replace iso = "MHL" if ccode == 983
		replace iso = "MRT" if ccode == 435
		replace iso = "MUS" if ccode == 590
		replace iso = "MEX" if ccode == 70
		replace iso = "MDA" if ccode == 359
		replace iso = "MCO" if ccode == 221
		replace iso = "MNG" if ccode == 712
		replace iso = "MNE" if ccode == 341
		replace iso = "MAR" if ccode == 600
		replace iso = "MOZ" if ccode == 541
		replace iso = "MMR" if ccode == 775
		replace iso = "NAM" if ccode == 565
		replace iso = "NRU" if ccode == 970
		replace iso = "NPL" if ccode == 790
		replace iso = "NLD" if ccode == 210
		replace iso = "NZL" if ccode == 920
		replace iso = "NIC" if ccode == 93
		replace iso = "NER" if ccode == 436
		replace iso = "NGA" if ccode == 475
		replace iso = "PRK" if ccode == 731
		replace iso = "NOR" if ccode == 385
		replace iso = "OMN" if ccode == 698
		replace iso = "PAK" if ccode == 770
		replace iso = "PLW" if ccode == 986
		replace iso = "PAN" if ccode == 95
		replace iso = "PNG" if ccode == 910
		replace iso = "PRY" if ccode == 150
		replace iso = "PER" if ccode == 135
		replace iso = "PHL" if ccode == 840
		replace iso = "POL" if ccode == 290
		replace iso = "PRT" if ccode == 235
		replace iso = "QAT" if ccode == 694
		replace iso = "ROU" if ccode == 360
		replace iso = "RUS" if ccode == 365
		replace iso = "RWA" if ccode == 517
		replace iso = "WSM" if ccode == 990
		replace iso = "SMR" if ccode == 331
		replace iso = "STP" if ccode == 403
		replace iso = "SAU" if ccode == 670
		replace iso = "SEN" if ccode == 433
		replace iso = "SYC" if ccode == 591
		replace iso = "SLE" if ccode == 451
		replace iso = "SGP" if ccode == 830
		replace iso = "SVK" if ccode == 317
		replace iso = "SVN" if ccode == 349
		replace iso = "SLB" if ccode == 940
		replace iso = "SOM" if ccode == 520
		replace iso = "ZAF" if ccode == 560
		replace iso = "KOR" if ccode == 732
		replace iso = "SSD" if ccode == 626
		replace iso = "ESP" if ccode == 230
		replace iso = "LKA" if ccode == 780
		replace iso = "KNA" if ccode == 60
		replace iso = "LCA" if ccode == 56
		replace iso = "VCT" if ccode == 57
		replace iso = "SDN" if ccode == 625
		replace iso = "SUR" if ccode == 115
		replace iso = "SWZ" if ccode == 572
		replace iso = "SWE" if ccode == 380
		replace iso = "CHE" if ccode == 225
		replace iso = "SYR" if ccode == 652
		replace iso = "TWN" if ccode == 713
		replace iso = "TJK" if ccode == 702
		replace iso = "TZA" if ccode == 510
		replace iso = "THA" if ccode == 800
		replace iso = "TGO" if ccode == 461
		replace iso = "TON" if ccode == 955
		replace iso = "TTO" if ccode == 52
		replace iso = "TUN" if ccode == 616
		replace iso = "TUR" if ccode == 640
		replace iso = "TKM" if ccode == 701
		replace iso = "TUV" if ccode == 947
		replace iso = "UGA" if ccode == 500
		replace iso = "UKR" if ccode == 369
		replace iso = "ARE" if ccode == 696
		replace iso = "GBR" if ccode == 200
		replace iso = "USA" if ccode == 2
		replace iso = "URY" if ccode == 165
		replace iso = "UZB" if ccode == 704
		replace iso = "VUT" if ccode == 935
		replace iso = "VEN" if ccode == 101
		replace iso = "VNM" if ccode == 816
		replace iso = "YEM" if ccode == 679
		replace iso = "YAR" if ccode == 678
		replace iso = "YPR" if ccode == 680
		replace iso = "YUG" if ccode == 345
		replace iso = "ZMB" if ccode == 551
		replace iso = "ZWE" if ccode == 552

		rename iso iso3b
		gen iso3a="CHN"
		rename totalPresPremvisits tripsabroad_KS_2003to2008

		order iso3a iso3b tripsabroad_KS_2003to2008
		keep iso3a iso3b tripsabroad_KS_2003to2008
		duplicates drop
		
		save KS-COLT_China-comparison_2003to2008.dta, replace	
		
		use JiangZhuReplication1.dta,clear
		
		gen iso = ""
		replace iso = "AFG" if ccode == 700
		replace iso = "ALB" if ccode == 339
		replace iso = "DZA" if ccode == 615
		replace iso = "AND" if ccode == 232
		replace iso = "AGO" if ccode == 540
		replace iso = "ATG" if ccode == 58
		replace iso = "ARG" if ccode == 160
		replace iso = "ARM" if ccode == 371
		replace iso = "AUS" if ccode == 900
		replace iso = "AUT" if ccode == 305
		replace iso = "AZE" if ccode == 373
		replace iso = "BHS" if ccode == 31
		replace iso = "BHR" if ccode == 692
		replace iso = "BGD" if ccode == 771
		replace iso = "BRB" if ccode == 53
		replace iso = "BLR" if ccode == 370
		replace iso = "BEL" if ccode == 211
		replace iso = "BLZ" if ccode == 80
		replace iso = "BEN" if ccode == 434
		replace iso = "BTN" if ccode == 760
		replace iso = "BOL" if ccode == 145
		replace iso = "BIH" if ccode == 346
		replace iso = "BWA" if ccode == 571
		replace iso = "BRA" if ccode == 140
		replace iso = "BRN" if ccode == 835
		replace iso = "BGR" if ccode == 355
		replace iso = "BFA" if ccode == 439
		replace iso = "BDI" if ccode == 516
		replace iso = "KHM" if ccode == 811
		replace iso = "CMR" if ccode == 471
		replace iso = "CAN" if ccode == 20
		replace iso = "CPV" if ccode == 402
		replace iso = "CAF" if ccode == 482
		replace iso = "TCD" if ccode == 483
		replace iso = "CHL" if ccode == 155
		replace iso = "CHN" if ccode == 710
		replace iso = "COL" if ccode == 100
		replace iso = "COM" if ccode == 581
		replace iso = "COG" if ccode == 484
		replace iso = "CRI" if ccode == 94
		replace iso = "HRV" if ccode == 344
		replace iso = "CUB" if ccode == 40
		replace iso = "CYP" if ccode == 352
		replace iso = "CZE" if ccode == 316
		replace iso = "CSK" if ccode == 315
		replace iso = "COD" if ccode == 490
		replace iso = "DNK" if ccode == 390
		replace iso = "DJI" if ccode == 522
		replace iso = "DMA" if ccode == 54
		replace iso = "DOM" if ccode == 42
		replace iso = "TLS" if ccode == 860
		replace iso = "ECU" if ccode == 130
		replace iso = "EGY" if ccode == 651
		replace iso = "SLV" if ccode == 92
		replace iso = "GNQ" if ccode == 411
		replace iso = "ERI" if ccode == 531
		replace iso = "EST" if ccode == 366
		replace iso = "ETH" if ccode == 530
		replace iso = "FSM" if ccode == 987
		replace iso = "FJI" if ccode == 950
		replace iso = "FIN" if ccode == 375
		replace iso = "FRA" if ccode == 220
		replace iso = "GAB" if ccode == 481
		replace iso = "GMB" if ccode == 420
		replace iso = "GEO" if ccode == 372
		replace iso = "DDR" if ccode == 265
		replace iso = "FRG" if ccode == 260
		replace iso = "DEU" if ccode == 255
		replace iso = "GHA" if ccode == 452
		replace iso = "GRC" if ccode == 350
		replace iso = "GRD" if ccode == 55
		replace iso = "GTM" if ccode == 90
		replace iso = "GIN" if ccode == 438
		replace iso = "GNB" if ccode == 404
		replace iso = "GUY" if ccode == 110
		replace iso = "HTI" if ccode == 41
		replace iso = "HND" if ccode == 91
		replace iso = "HUN" if ccode == 310
		replace iso = "ISL" if ccode == 395
		replace iso = "IND" if ccode == 750
		replace iso = "IDN" if ccode == 850
		replace iso = "IRN" if ccode == 630
		replace iso = "IRQ" if ccode == 645
		replace iso = "IRL" if ccode == 205
		replace iso = "ISR" if ccode == 666
		replace iso = "ITA" if ccode == 325
		replace iso = "CIV" if ccode == 437
		replace iso = "JAM" if ccode == 51
		replace iso = "JPN" if ccode == 740
		replace iso = "JOR" if ccode == 663
		replace iso = "KAZ" if ccode == 705
		replace iso = "KEN" if ccode == 501
		replace iso = "KIR" if ccode == 946
		replace iso = "XKX" if ccode == 347
		replace iso = "KWT" if ccode == 690
		replace iso = "KGZ" if ccode == 703
		replace iso = "LAO" if ccode == 812
		replace iso = "LVA" if ccode == 367
		replace iso = "LBN" if ccode == 660
		replace iso = "LSO" if ccode == 570
		replace iso = "LBR" if ccode == 450
		replace iso = "LBY" if ccode == 620
		replace iso = "LIE" if ccode == 223
		replace iso = "LTU" if ccode == 368
		replace iso = "LUX" if ccode == 212
		replace iso = "MKD" if ccode == 343
		replace iso = "MDG" if ccode == 580
		replace iso = "MWI" if ccode == 553
		replace iso = "MYS" if ccode == 820
		replace iso = "MDV" if ccode == 781
		replace iso = "MLI" if ccode == 432
		replace iso = "MLT" if ccode == 338
		replace iso = "MHL" if ccode == 983
		replace iso = "MRT" if ccode == 435
		replace iso = "MUS" if ccode == 590
		replace iso = "MEX" if ccode == 70
		replace iso = "MDA" if ccode == 359
		replace iso = "MCO" if ccode == 221
		replace iso = "MNG" if ccode == 712
		replace iso = "MNE" if ccode == 341
		replace iso = "MAR" if ccode == 600
		replace iso = "MOZ" if ccode == 541
		replace iso = "MMR" if ccode == 775
		replace iso = "NAM" if ccode == 565
		replace iso = "NRU" if ccode == 970
		replace iso = "NPL" if ccode == 790
		replace iso = "NLD" if ccode == 210
		replace iso = "NZL" if ccode == 920
		replace iso = "NIC" if ccode == 93
		replace iso = "NER" if ccode == 436
		replace iso = "NGA" if ccode == 475
		replace iso = "PRK" if ccode == 731
		replace iso = "NOR" if ccode == 385
		replace iso = "OMN" if ccode == 698
		replace iso = "PAK" if ccode == 770
		replace iso = "PLW" if ccode == 986
		replace iso = "PAN" if ccode == 95
		replace iso = "PNG" if ccode == 910
		replace iso = "PRY" if ccode == 150
		replace iso = "PER" if ccode == 135
		replace iso = "PHL" if ccode == 840
		replace iso = "POL" if ccode == 290
		replace iso = "PRT" if ccode == 235
		replace iso = "QAT" if ccode == 694
		replace iso = "ROU" if ccode == 360
		replace iso = "RUS" if ccode == 365
		replace iso = "RWA" if ccode == 517
		replace iso = "WSM" if ccode == 990
		replace iso = "SMR" if ccode == 331
		replace iso = "STP" if ccode == 403
		replace iso = "SAU" if ccode == 670
		replace iso = "SEN" if ccode == 433
		replace iso = "SYC" if ccode == 591
		replace iso = "SLE" if ccode == 451
		replace iso = "SGP" if ccode == 830
		replace iso = "SVK" if ccode == 317
		replace iso = "SVN" if ccode == 349
		replace iso = "SLB" if ccode == 940
		replace iso = "SOM" if ccode == 520
		replace iso = "ZAF" if ccode == 560
		replace iso = "KOR" if ccode == 732
		replace iso = "SSD" if ccode == 626
		replace iso = "ESP" if ccode == 230
		replace iso = "LKA" if ccode == 780
		replace iso = "KNA" if ccode == 60
		replace iso = "LCA" if ccode == 56
		replace iso = "VCT" if ccode == 57
		replace iso = "SDN" if ccode == 625
		replace iso = "SUR" if ccode == 115
		replace iso = "SWZ" if ccode == 572
		replace iso = "SWE" if ccode == 380
		replace iso = "CHE" if ccode == 225
		replace iso = "SYR" if ccode == 652
		replace iso = "TWN" if ccode == 713
		replace iso = "TJK" if ccode == 702
		replace iso = "TZA" if ccode == 510
		replace iso = "THA" if ccode == 800
		replace iso = "TGO" if ccode == 461
		replace iso = "TON" if ccode == 955
		replace iso = "TTO" if ccode == 52
		replace iso = "TUN" if ccode == 616
		replace iso = "TUR" if ccode == 640
		replace iso = "TKM" if ccode == 701
		replace iso = "TUV" if ccode == 947
		replace iso = "UGA" if ccode == 500
		replace iso = "UKR" if ccode == 369
		replace iso = "ARE" if ccode == 696
		replace iso = "GBR" if ccode == 200
		replace iso = "USA" if ccode == 2
		replace iso = "URY" if ccode == 165
		replace iso = "UZB" if ccode == 704
		replace iso = "VUT" if ccode == 935
		replace iso = "VEN" if ccode == 101
		replace iso = "VNM" if ccode == 816
		replace iso = "YEM" if ccode == 679
		replace iso = "YAR" if ccode == 678
		replace iso = "YPR" if ccode == 680
		replace iso = "YUG" if ccode == 345
		replace iso = "ZMB" if ccode == 551
		replace iso = "ZWE" if ccode == 552

		rename iso iso3b
		gen iso3a="CHN"
		rename totalPresPremvisits tripsabroad_KS_1998to2003

		order iso3a iso3b tripsabroad_KS_1998to2003
		keep iso3a iso3b tripsabroad_KS_1998to2003
		duplicates drop	
		
		merge 1:1 iso3b using "KS-COLT_China-comparison_2003to2008.dta"	
		drop _merge
		gen tripsabroad_KS = tripsabroad_KS_1998to2003 + tripsabroad_KS_2003to2008
		drop if tripsabroad_KS==.
		drop tripsabroad_KS_1998to2003 tripsabroad_KS_2003to2008
		browse
		
		save KS-COLT_US-comparison.dta, replace	
		
		*prep COLT
		clear
		import excel "Diplometrics_COLT_Travel_Dataset_20240711.xlsx", sheet("Master") firstrow
		
		keep if LeaderCountryISO=="CHN" & PriorityLeader=="Yes" & inrange(TripYear,1998,2018)
		gen one = 1
		egen tripsabroad_COLT = total(one),by(CountryVisitedISO)	
		
		rename LeaderCountryISO iso3a
		rename CountryVisitedISO iso3b
		rename CountryVisited, lower
		order iso3a countryvisited iso3b tripsabroad_COLT
		keep iso3a countryvisited iso3b tripsabroad_COLT
		drop if iso3a==iso3b /*COLT includes Chinese leader trips to HK*/
		duplicates drop
		browse
		
		save COLT-China-leader_by-country-data-prep.dta, replace	
		
		use KS-COLT_US-comparison.dta, clear
		merge 1:1 iso3a iso3b using "COLT-China-leader_by-country-data-prep.dta"
		drop _merge
		replace tripsabroad_KS = 0 if tripsabroad_KS==.
		replace tripsabroad_COLT=0 if tripsabroad_COLT==.
		drop if tripsabroad_KS==0 & tripsabroad_COLT==0
		replace countryvisited = "Angola" if iso3b == "AGO"
		
		replace countryvisited = "Bulgaria" if iso3b == "BGR"
		replace countryvisited = "Ethiopia" if iso3b == "ETH"
		replace countryvisited = "Ghana" if iso3b == "GHA"
		replace countryvisited = "Ireland" if iso3b == "IRL"
		replace countryvisited = "Luxembourg" if iso3b == "LUX"
		replace countryvisited = "Nepal" if iso3b == "NPL"
		replace countryvisited = "Uganda" if iso3b == "UGA"
									
		browse
		order iso3a iso3b countryvisited
		save KS-COLT_US-comparison_merged.dta, replace	
		
		*compare
		corr tripsabroad_KS tripsabroad_COLT
		graph hbar tripsabroad_KS tripsabroad_COLT,over(countryvisited,sort(tripsabroad_COLT) lab(labsize(zero)labcolor(gs15)))/*
		*/legend(cols(1)size(small)label(1 "Kastner & Saunders (2012)")label(2 "COLT (President only)")) /*
		*/ytitle("Visits, 1998-2008") scheme(s2mono) text(15.5 80 "r = 0.820",place(e)) title("Chinese President & Premier",size(medium))
		graph save KS-COLT_China-comparison_raw.gph, replace
		browse
		
	***Lebovic & Saunders (2016) - US President

		*prep L&S
		use diplomatic_core.replication.dta,clear

		keep if bi_PRE!=0 & bi_PRE!=.

		gen one = 1
		egen tripsabroad_LS = total(one),by(year)

		gen countrya="United States"
		gen iso3a="USA"
		order countrya iso3a year tripsabroad
		
		keep countrya iso3a year tripsabroad
		duplicates drop
		sort iso3a year
		keep if year>1989
		browse

		save LS-COLT_US-comparison.dta, replace	
		
		*prep COLT
		clear
		import excel "Diplometrics_COLT_Travel_Dataset_20240711.xlsx", sheet("Master") firstrow
		
		keep if LeaderCountryISO=="USA" & PriorityLeader=="Yes" & inrange(TripYear,1990,2012)
		gen one = 1
		egen tripsabroad_COLT = total(one),by(TripYear)
		
		rename TripYear year
		rename LeaderCountryISO iso3a
		order iso3a year tripsabroad_COLT
		
		keep iso3a year tripsabroad_COLT
		duplicates drop
		browse
		save COLT-US-leader-data-prep.dta, replace
		
		clear
		use LS-COLT_US-comparison.dta
		merge 1:1 iso3a year using "COLT-US-leader-data-prep.dta"
		drop _merge
		save LS-COLT_US-comparison_merged.dta, replace
		
		*compare
		corr tripsabroad_LS tripsabroad_COLT
		twoway(line tripsabroad_LS year)(line tripsabroad_COLT year),legend(label(1 "Lebovic & Saunders (2016)")label(2 "COLT")) xtitle("") /*
		*/ylabel(,angle(horizontal)) ytitle("Trips abroad") title("President of the United States") text(27.5 2009.5 "r = 0.968",place(e))
		graph save LS-COLT_US-comparison.gph, replace	
		
	***Balci & Pulat (2024) - Turkish President & Prime Minister

		*prep B&P	
		use TRLeaderVisits.dta, clear
		
		keep if year>1989
			*Winnow to priority HOGS
			drop if year<2014 & status=="President"
			drop if year>2014 & status=="Prime Minister"
			drop if year==2014 & leader!="Recep Tayyip Erdoğan"
		browse
		
		gen one = 1
		egen tripsabroad_BP = total(one),by(year)
		gen iso3a = "TUR"
		order iso3a year tripsabroad_BP
		keep iso3a year tripsabroad_BP
		duplicates drop
		drop if year==.
		
		save BP-COLT_TUR-comparison.dta, replace		
		
		*prep COLT
		clear
		import excel "Diplometrics_COLT_Travel_Dataset_20240711.xlsx", sheet("Master") firstrow
		
		keep if LeaderCountryISO=="TUR" & PriorityLeader=="Yes" & inrange(TripYear,1990,2022)
		gen one = 1
		egen tripsabroad_COLT = total(one),by(TripYear)
		
		rename TripYear year
		rename LeaderCountryISO iso3a
		order iso3a year tripsabroad_COLT
		
		keep iso3a year tripsabroad_COLT
		duplicates drop
		browse
		save COLT-TUR-leader-data-prep.dta, replace	
		
		clear
		use BP-COLT_TUR-comparison.dta
		merge 1:1 iso3a year using "COLT-TUR-leader-data-prep.dta"
		drop _merge
		browse
		save BP-COLT_TUR-comparison_merged.dta, replace	
		
		*compare
		corr tripsabroad_BP tripsabroad_COLT
		twoway(line tripsabroad_BP year)(line tripsabroad_COLT year),legend(label(1 "Balci & Pulat (2024)")label(2 "COLT")) xtitle("") /*
		*/ylabel(,angle(horizontal)) ytitle("Trips abroad") title("President/Prime Minister of Turkey") text(45 2017 "r = 0.956",place(e))
		graph save BP-COLT_Turkey-comparison.gph, replace		
		
	*all
		graph combine WS-COLT_China-comparison.gph LS-COLT_US-comparison.gph BP-COLT_Turkey-comparison.gph,rows(3)
		graph save Graph "WS-LS-BP-COLT_comparisons-combined_raw.gph", replace

		*Figure 1
		graph combine WS-LS-BP-COLT_comparisons-combined_raw.gph KS-COLT_China-comparison_raw.gph
		graph save Graph "All-COLT_comparisons-combined.gph", replace

********************************************************************************
**Descriptive analysis
********************************************************************************
	
	*Summary stats for Table 1
		use "HOGS_monadic_panel-for-analysis.dta", clear
		sum tripsin tripsin_blat tripsin_mlat tripsout tripsout_blat tripsout_mlat 
		
		use COLT_Dyadic_for-regression-analysis_20240711.dta, clear
		sum tripsatob tripsatob_bilateralevent tripsatob_multilatevent
		
	*Global trip count
		egen globalannualtotal = total(tripsatob), by(year)
		browse year globalannualtotal if directeddyadid==1
		
		preserve
			keep year globalannualtotal
			duplicates drop
			save global-trips-per-year.dta, replace
		restore
		
		use Ten-pct-recognition_independence_count.dta, clear /*Pardee MIS list*/
		keep if country=="World"
		keep year independence_count
		save number_of_10pctrecog-states.dta, replace
		
		use global-trips-per-year.dta, clear
		merge 1:1 year using "number_of_10pctrecog-states.dta"
		drop _merge
		
		gen globaltrips_normalized = globalannualtotal/independence_count
		tsset year
		gen growth_pct_norm = ((globaltrips_normalized/l.globaltrips_normalized)*100)-100
		sum growth_pct_norm
	
	*Figure 2
		use HOGS_monadic_panel-for-analysis.dta, clear
		egen totaltripsout = total(tripsout),by(country)
		egen totaltripsin = total(tripsin),by(country)
		keep country totaltripsout totaltripsin
		preserve
			keep country totaltripsout
			gsort -totaltripsout
			drop country
			duplicates drop
			gen n = _n
			save alltripsout.dta, replace
		restore
		keep country totaltripsin
		gsort -totaltripsin
		drop country
		duplicates drop		
		gen n = _n
		save alltripsin.dta, replace
		merge 1:1 n using alltripsout.dta
		
		twoway(line totaltripsout n, lcolor(green) lwidth(thick))(line totaltripsin n, lcolor(orange)/*
		*/lwidth(thick)),ylabel(1000 "1,000" 2000 "2,000" 3000 "3,000" 4000 "4,000" 5000 "5,000" /*
		*/6000 "6,000",angle(0)) ytitle("Count of trips") xtitle("All countries ranked")/*
		*/legend(label(1 "All trips out")label(2 "All trips in"))
		graph save Graph "Trips-in-Trips-out_line.gph", replace
	
	/*
	*Figure 2 -- alternate: Histogram
		use HOGS_monadic_panel-for-analysis.dta, clear
		hist tripsout, freq color(black%20) addplot(hist tripsin, freq fcolor(none) /*
		*/lcolor(black)) legend(cols(2) label(1 "Trips out")label(2 "Trips in")) /*
		*/xtitle("Trip count",size(medium)) ylabel(,angle(horizontal) format(%6.0fc)) ytitle("Count of country-years")
		graph save Graph "Trips-in-Trips-out_hist.gph", replace
	*/
	
	*Figure 3 - built in DataWrapper (https://www.datawrapper.de/_/bQ3Qb/)
		preserve
			gen netin = tripsin-tripsout
			egen netin_avg = mean(netin),by(country)
			keep country netin_avg
			duplicates drop
			save monadic_net-in-visits.dta, replace
		restore

	*Intra-regime-type flows
	gen democ = .
	gen autoc = .
	replace autoc = 0 if v2x_polyarchy!=.
	replace democ = 0 if v2x_polyarchy!=.
	replace autoc = 1 if v2x_polyarchy!=. & v2x_polyarchy<0.42
	replace democ = 1 if v2x_polyarchy!=. & v2x_polyarchy>=0.42
	sum democ autoc
	bysort democ: sum tripsin
	bysort democ: sum tripsout

	use "COLT_Dyadic_for-regression-analysis_20240711.dta", clear
	gen democa = .
	gen autoca = .
	replace autoca = 0 if v2x_polyarchy_a!=.
	replace democa = 0 if v2x_polyarchy_a!=.
	replace autoca = 1 if v2x_polyarchy_a!=. & v2x_polyarchy_a<0.42
	replace democa = 1 if v2x_polyarchy_a!=. & v2x_polyarchy_a>=0.42	
	
	gen democb = .
	gen autocb = .
	replace autocb = 0 if v2x_polyarchy_b!=.
	replace democb = 0 if v2x_polyarchy_b!=.
	replace autocb = 1 if v2x_polyarchy_b!=. & v2x_polyarchy_b<0.42
	replace democb = 1 if v2x_polyarchy_b!=. & v2x_polyarchy_b>=0.42
	
	gen jointdemoc = .
	replace jointdemoc = 0 if v2x_polyarchy_a!=. & v2x_polyarchy_b!=.
	replace jointdemoc = 1 if democa==1 & democb==1
	
	preserve
		keep if jointdemoc==1
		egen democtodemoctrips = total(tripsatob)
		sum democtodemoctrips
	restore
	
	gen jointautoc = .
	replace jointautoc = 0 if v2x_polyarchy_a!=. & v2x_polyarchy_b!=.
	replace jointautoc = 1 if autoca==1 & autocb==1	
		
	preserve
		keep if jointautoc==1
		egen autoctoautoctrips = total(tripsatob)
		sum autoctoautoctrips
	restore
	
	preserve
		keep if autoca== 1 & democb==1 
		egen autoctodemoctrips = total(tripsatob)
		sum autoctodemoctrips
	restore		
	
	preserve
		keep if autoca== 0 & democb==0 
		egen democtoautoctrips = total(tripsatob)
		sum democtoautoctrips
	restore		

********************************************************************************
**Regression analysis
********************************************************************************


********** Monadic correlates of travel
	use "HOGS_monadic_panel-for-analysis.dta", clear
						
	tsset a1 year 
		
	*Test for serial correlation
		xtserial tripsin tripsout gdpmer2011usda gdppc_ppp v2x_polyarchy tradepctgdp beckley sb_exist_cy avg_unga_coincidence fuelexppctmerchexp igocount allies arms, output

		**** SET VARLIST 1 *** 
		global varlist gdpmer2011usda gdppc_ppp v2x_polyarchy tradepctgdp beckley sb_exist_cy avg_unga_coincidence fuelexppctmerchexp igocount allies arms
				
	*Z-standardize
	center $varlist, inplace standardize /*z-standardize for coefplots*/
	
	*Regressions
		***Model 1
			ppmlhdfe tripsout $varlist, a(a1 year) cluster(a1)
			estimates store pmle1

		***Model 2
			ppmlhdfe tripsin $varlist, a(a1 year) cluster(a1)
			estimates store pmle2
	
	*Figure 5	
		*plot
			coefplot(pmle1)(pmle2),drop(_cons)xline(0) /*
			*/rename(gdpmer2011usda = "GDP (MER)" gdppc_ppp = "GDP (PPP) per capita"/*
			*/v2x_polyarchy = "Polyarchy" /*
			*/tradepctgdp = "Trade openness" beckley = "Power" /*
			*/sb_exist_cy = "Conflict" avg_unga_coincidence = "Avg. UNGA voting coincidence" /*
			*/fuelexppctmerchexp = "Fuel exports % of goods exports*" /*
			*/igocount = "IGO memberships" allies = "Number of allies" /*
			*/arms = "Arms transfers")/*
			*/xlabel(,labsize(small)) ylabel(,labsize(small)) /*
			*/note("Note: Where consistent across both models * = p<0.05, ** = p<0.01" /*
			*/"Confidence intervals that do not cross zero indicate p<0.05") /*
			*/legend(label(2 "All Out-visits")label(4 "All In-visits")) xtitle("Standardized coefficients")

********** Dyadic correlates of travel
	use "COLT_Dyadic_for-regression-analysis_20240711.dta", clear

	**** SET VARLIST 2 *** 
	global varlist2 reciprocity gdppc_ppp_a gdppc_ppp_b sb_exist_cya v2x_polyarchy_a powershare_a distanceatob polyarchyaffinity unga_coincidence atopally totaltradeawithb foreignaid2011usdatob armsexportsatob embassylorainb embassylorbina

	xtserial tripsatob tripsbtoa $varlist2, output
	
	*Z-standardize
	center $varlist2, inplace standardize /*z-standardize for coefplots*/
	
	*Regressions
		***Model 3
			ppmlhdfe tripsatob l.tripsatob $varlist2, a(a1 b1 year) cluster(a1 b1)
			estimates store pmle3

		***Model 4
			ppmlhdfe tripsbtoa l.tripsbtoa $varlist2, a(a1 b1 year) cluster(a1 b1)
			estimates store pmle4
				
	*Figure 4
		*plot
			graph set window fontface "Times New Roman"
			coefplot(pmle3)(pmle4),drop(_cons) xline(0) /*
			*/rename(tripsatob = "Lagged DV**" reciprocity = "Reciprocity**" /*
			*/gdppc_ppp_a = "GDP (PPP) per capita, A" gdppc_ppp_b = "GDP (PPP) per capita, B" /*
			*/sb_exist_cya = "Conflict, A" v2x_polyarchy_a = "Polyarchy, A" /*
			*/distanceatob = "Distance, A to B**" powershare_a = "Power share, A" /*
			*/polyarchyaffinity = "Polyarchy affinity*" unga_coincidence = "UNGA voting coincidence**" /*
			*/atopally = "Alliance**" totaltradeawithb = "Good trade, A with B**" /*
			*/foreignaid2011usdatob = "Aid, A to B**" armsexportsatob = "Arms transfers, A to B**" /*
			*/embassylorainb = "Embassy, A in B**" embassylorbina = "Embassy, B in A**") /*
			*/headings("GDP (PPP) per capita, A" = "{bf:Monadic}" "Distance, A to B**" = "{bf:Shared Dyadic}" /*
			*/"Aid, A to B**" = "{bf:Directed Dyadic}") /*
			*/xlabel(,labsize(small)) ylabel(,labsize(small)) /*
			*/note("Note: Where consistent across both models * = p<0.05, ** = p<0.01" /*
			*/"Confidence intervals that do not cross zero indicate p<0.05") /*
			*/legend(label(2 "Trips, A to B")label(4 "Trips, B to A")) xtitle("Standardized coefficients")
		
********** Dyadic trade & travel
		use "COLT_Dyadic_for-regression-analysis_20240711.dta", clear						
		encode countrya, gen(countrya1)
		encode countryb, gen(countryb1)
		gen undyada = cond(countrya1 < countryb1, countrya1, countryb1)
		gen undyadb = cond(countrya1 < countryb1, countryb1, countrya1)
		egen dyadid = group(undyada undyadb)
		gen gdpmerbil_a = gdpmer2011usda/1000000000
		gen gdpmerbil_b = gdpmer2011usdb/1000000000
		gen totaltradeawithb_bil = totaltradeawithb/1000000000
		global varlist3 l.gdpmerbil_a  l.gdpmerbil_b l.powershare_a l.embassylorainb l.embassylorbina l.atopally l.tradeagreement_rta l.armsexportsatob l.v2x_polyarchy_a l.polyarchyaffinity l.unga_coincidence l.sb_exist_cya l.sb_exist_cyb l.fdioutstocks2011usdatob l.tripsatob_bilatevent_withmeeting l.tripsbtoa_bilatevent_withmeeting
		xtset directeddyadid year
		
	*Regressions for Table 2
		ppmlhdfe totaltradeawithb l.totaltradeawithb_bil $varlist3, a(directeddyadid year)
		global varlist4 l.gdpmerbil_a l.gdpmerbil_b l.powershare_a l.embassylorainb l.embassylorbina l.atopally l.tradeagreement_rta l.armsexportsatob l.v2x_polyarchy_a l.polyarchyaffinity l.unga_coincidence l.sb_exist_cya l.sb_exist_cyb l.fdioutstocks2011usdatob l.totaltradeawithb_bil	
		ppmlhdfe tripsatob_bilatevent_withmeeting l.tripsatob_bilatevent_withmeeting l.tripsbtoa_bilatevent_withmeeting $varlist4, a(directeddyadid year)

		*Checking difference between major and minor powers:
		
			gen majpowa = 0
			replace majpowa =1 if inlist(countrya, "United States","United Kingdom","Soviet Union","Russia","Japan","Germany","France","China")
			gen majpowb = 0
			replace majpowb =1 if inlist(countryb, "United States","United Kingdom","Soviet Union","Russia","Japan","Germany","France","China")
			
			gen majpowdyad = 0
			replace majpowdyad = 1 if majpowa==1|majpowb==1
			
			*dyads with at least one major power (COW: P5 + Germany & Japan)
			ppmlhdfe totaltradeawithb l.totaltradeawithb_bil $varlist3 if majpowdyad==1, a(directeddyadid year)
			ppmlhdfe tripsatob_bilatevent_withmeeting l.tripsatob_bilatevent_withmeeting l.tripsbtoa_bilatevent_withmeeting $varlist4 if majpowdyad==1, a(directeddyadid year)
			
			*dyads without a major power
			ppmlhdfe totaltradeawithb l.totaltradeawithb_bil $varlist3 if majpowdyad==0, a(directeddyadid year)
			ppmlhdfe tripsatob_bilatevent_withmeeting l.tripsatob_bilatevent_withmeeting l.tripsbtoa_bilatevent_withmeeting $varlist4 if majpowdyad==0, a(directeddyadid year)
